#include<iostream>
#include<stdlib.h>
using namespace std;

class  BinaryTree
{
protected:
	typedef struct BtNode
	{
		char data;
		BtNode * leftchild;
		BtNode * rightchild;


	// sdusidu
	};
	typedef BtNode* PBtree;

private:
	BtNode * root;//���ڵ�
	//Type RefValue;//Ҷ�ӽڵ�ı�־
	
	static BtNode *Copy(const BtNode *p)
	{
		BtNode *newroot;
		if (NULL == p)
			return NULL;
		else
		{
			newroot->data = p->data;
			newroot->leftchild = Copy(p->leftchild);
			newroot->rightchild = Copy(p->rightchild);
		}
	}
public:
	BinaryTree() :root(NULL){}
	/*BinaryTree( BinaryTree) 
	{
		root = Copy(tree.root);
	}*/
	BinaryTree & operator=(BinaryTree &obj)
	{
		if (this != &obj)
		{
			root = Copy(obj.root);
		}
		return *this;
	}
	/*void MakeTree(const Type *&str)
	{
		if (NULL == str)
		{
			root = NULL;
		}
		else
		{
			root = Create(str);
		}
	}*/
	BtNode *Create()
	{
		char *str;
		cin >> str;
		if (*str == '#')
			return NULL;
		else 
		{
			BtNode *s = new BtNode;
			if (*str < s->data) 
			{
				s->leftchild = Create1(str);
			}
			else
			{
				if (*str > s->data)
				{
					s->rightchild = Create1(str);
				}
				else
				{
					s->data = *str;
				}
			}
		}
	}
	BtNode * Create1(char *&str) 
	{
		if ('#' == *str)
			return NULL;
		else
		{
			BtNode *s = new BtNode;
			s->data =* str;
			s->leftchild = Create1(++str);
			s->rightchild = Create1(++str);
			return s;
		}
	}
	~BinaryTree()
	{

	}
	
	BtNode * ReCreateBt(char*pre, char *in, int n)
	{
		/*
		*pre����������У�in����������У�nΪ�������ڵ����
		*���ض��������Ľڵ�ָ��
		*/
		BtNode *b;
		char *p;
		int k;
		if (n < 0)
			return NULL;
		b = new BtNode;
		b->data = *pre;
		for (p = in; p < in + n; p++)//�ҵ����ڵ��������е�λ��
		{
			if (*p == *pre)
				break;
		}
		k = p - in;//
		b->leftchild = ReCreateBt(pre + 1, in, k);
		b->rightchild= ReCreateBt(pre +k+1, p+1,n-k-1);
		return b;
	}
	BtNode * Conversion(BtNode *r)
	{
		BtNode *p;
		p = r->leftchild;
		r->leftchild = r->rightchild;
		r->rightchild = p;
		Conversion(r->leftchild);
		Conversion(r->rightchild);
		return root;
	}
};
void main()
{
	BinaryTree * t = new BinaryTree();
	//t.root=Create();
}
